package com.hjm.project.finance.AgentDeductionsKf.controller;

import java.util.List;

import com.hjm.project.job.task.service.IJobTaskService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.finance.AgentDeductionsKf.domain.AgentDeductionsKf;
import com.hjm.project.finance.AgentDeductionsKf.service.IAgentDeductionsKfService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;

import javax.annotation.Resource;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 代理商还款明细Controller
 * 
 * @author maker-platform
 * @date 2022-10-26
 */
@Controller
@RequestMapping("/finance/AgentDeductionsKf")
public class AgentDeductionsKfController extends BaseController {
    private String prefix = "finance/AgentDeductionsKf";

    @Resource
    private IAgentDeductionsKfService agentDeductionsKfService;
    @Resource
    private IJobTaskService jobTaskService;

    @RequiresPermissions("finance:AgentDeductionsKf:view")
    @GetMapping()
    public String AgentDeductionsKf() {
        return prefix + "/AgentDeductionsKf";
    }

    /**
     * 查询代理商还款明细列表
     */
    @RequiresPermissions("finance:AgentDeductionsKf:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AgentDeductionsKf agentDeductionsKf) {
        startPage();
        List<AgentDeductionsKf> list = agentDeductionsKfService.selectAgentDeductionsKfList(agentDeductionsKf);
        return getDataTable(list);
    }

    /**
     * 导出代理商还款明细列表
     */
    @RequiresPermissions("finance:AgentDeductionsKf:export")
    @Log(title = "代理商还款明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AgentDeductionsKf agentDeductionsKf) {
        agentDeductionsKfService.export(agentDeductionsKf,this.getSysUser().getLoginName());
        return AjaxResult.success("操作成功，前往下载队列查看");
    }

    /**
     * 新增代理商还款明细
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存代理商还款明细
     */
    @RequiresPermissions("finance:AgentDeductionsKf:add")
    @Log(title = "代理商还款明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AgentDeductionsKf agentDeductionsKf) {
        return toAjax(agentDeductionsKfService.insertAgentDeductionsKf(agentDeductionsKf));
    }

    /**
     * 修改代理商还款明细
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap) {
        AgentDeductionsKf agentDeductionsKf = agentDeductionsKfService.selectAgentDeductionsKfById(id);
        mmap.put("agentDeductionsKf", agentDeductionsKf);
        return prefix + "/edit";
    }

    /**
     * 修改保存代理商还款明细
     */
    @RequiresPermissions("finance:AgentDeductionsKf:edit")
    @Log(title = "代理商还款明细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AgentDeductionsKf agentDeductionsKf) {
        return toAjax(agentDeductionsKfService.updateAgentDeductionsKf(agentDeductionsKf));
    }

    /**
     * 删除代理商还款明细
     */
    @RequiresPermissions("finance:AgentDeductionsKf:remove")
    @Log(title = "代理商还款明细", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(agentDeductionsKfService.deleteAgentDeductionsKfByIds(ids));
    }
}
